<?php
/*
 * Author:  Somnath Shinde- soma.shinde@gmail.com Mobile No:- 9423792564
 * 
 * Create Date: 
 * 
 * Version of MYSQL_to_PHP: 1.1
 * 
 * Ranzani( YZ'S );
 * 
 */
//require_once 'classes/DataBaseMysql.class.php';

Class BaseDiagnosisTypes {

	protected $m_intId;
	protected $m_strName;
	protected $m_strDescription;
	protected $m_strDepatmentDetails;
	protected $m_intIsPublished;
	protected $m_intOrderNumber;
	protected $connection;

	public function  __construct() {
		if( true == isset( $_SERVER['connection'] ) ) {
			$this->connection = $_SERVER['connection'];
		}
	}

	
	/*******************************************************************************************
	******************************** get Functions *********************************************
	*******************************************************************************************/

	public function getId(){
		return $this->m_intId;
	}

	public function getName(){
		return $this->m_strName;
	}

	public function getDescription(){
		return $this->m_strDescription;
	}

	public function getDepatmentDetails(){
		return $this->m_strDepatmentDetails;
	}

	public function getIsPublished(){
		return $this->m_intIsPublished;
	}

	public function getOrderNumber(){
		return $this->m_intOrderNumber;
	}
	
	/*******************************************************************************************
	********************************* set Functions ********************************************
	*******************************************************************************************/

	public function setId( $Id ){
		$this->m_intId = $Id;
	}

	public function setName( $Name ){
		$this->m_strName = $Name;
	}

	public function setDescription( $Description ){
		$this->m_strDescription = $Description;
	}

	public function setDepatmentDetails( $DepatmentDetails ){
		$this->m_strDepatmentDetails = $DepatmentDetails;
	}

	public function setIsPublished( $IsPublished ){
		$this->m_intIsPublished = $IsPublished;
	}

	public function setOrderNumber( $OrderNumber ){
		$this->m_intOrderNumber = $OrderNumber;
	}
	
	/*******************************************************************************************
	********************************* Insert Functions ********************************************
	*******************************************************************************************/

	public function insert(){
		return $this->connection->RunQuery( "Insert into DIAGNOSIS_TYPES (name, description, depatment_details, is_published, order_number) values ('" . $this->getName() . "', '" . $this->getDescription() . "', '" . $this->getDepatmentDetails() . "', " . $this->getIsPublished() . ", " . $this->getOrderNumber() . ")");
	}
	
	/*******************************************************************************************
	********************************* Update Functions ********************************************
	*******************************************************************************************/

	public function update(){
		return $this->connection->RunQuery( "UPDATE DIAGNOSIS_TYPES set  name= '" . $this->getName() . "', description= '" . $this->getDescription() . "', depatment_details= '" . $this->getDepatmentDetails() . "', is_published= " . $this->getIsPublished() . ", order_number= " . $this->getOrderNumber() . " where id =" . $this->getId() );
	}
	
	/*******************************************************************************************
	********************************* Delete Functions ********************************************
	*******************************************************************************************/

	public function Delete($intId ) {
		$this->connection->RunQuery( "DELETE FROM diagnosis_types WHERE id = $intId");
	}

	public function fetchNextId() {
		$result = $this->connection->RunQuery( "SELECT AUTO_INCREMENT as id FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = 'diagnosis_types'" );
		if( false == $result ) return NULL;

		while( $row = $result->fetch_array( MYSQLI_ASSOC ) ) {
			$this->id = $row["id"];
		}

		return $this->id;
	}

}